﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <el-form ref="formRefStation" :model="stateStation.vmModel" label-width="100px">
    <div>{{$t('message.autotrans.SysBatchEditConfirm')}}</div>
    <el-row>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_LineCodeId_FormItem" prop="LinkedVM.LineCodeId" :label="$t('message.autotrans._Model_Station_LineCode')"          :rules="[{required: true, message: $t('message._system.common.vm.input',{input:$t('message.autotrans._Model_Station_LineCode')}), trigger: 'blur' }]" >
          <el-select v-model="stateStation.vmModel.LinkedVM.LineCodeId" filterable clearable>
             <el-option v-for="item in stateStation.AllLineCodes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_StationName_FormItem" prop="LinkedVM.StationName" :label="$t('message.autotrans._Model_Station_StationName')">
          <el-input v-model="stateStation.vmModel.LinkedVM.StationName" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_Base_Status_FormItem" prop="LinkedVM.Base_Status" :label="$t('message.autotrans._Model_Station_Base_Status')">
          <el-select v-model="stateStation.vmModel.LinkedVM.Base_Status" clearable>
             <el-option key="CREATED" value="CREATED" :label="$t('message.autotrans._Enum_BaseStatus_CREATED')"></el-option>
             <el-option key="USED" value="USED" :label="$t('message.autotrans._Enum_BaseStatus_USED')"></el-option>
             <el-option key="FORBIDDEN" value="FORBIDDEN" :label="$t('message.autotrans._Enum_BaseStatus_FORBIDDEN')"></el-option>
          </el-select>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_StationManagerID_FormItem" prop="LinkedVM.StationManagerID" :label="$t('message.autotrans._Model_Station_StationManagerID')">
          <el-input v-model="stateStation.vmModel.LinkedVM.StationManagerID" clearable></el-input>
      </el-form-item>

      </el-col>
      <el-col :xs="24" :lg="12" class="mb20">
      <el-form-item ref="LinkedVM_StationManagerName_FormItem" prop="LinkedVM.StationManagerName" :label="$t('message.autotrans._Model_Station_StationManagerName')">
          <el-input v-model="stateStation.vmModel.LinkedVM.StationManagerName" clearable></el-input>
      </el-form-item>

      </el-col>
    </el-row>

    <div style="text-align:right;">
      <WtmButton @click="onSubmitStation"  type="primary" :button-text="$t('message.autotrans.SysSubmit')" style="margin-top:15px;"/>

      <WtmButton @click="onCloseStation"  type="primary" :button-text="$t('message.autotrans.SysClose')" style="margin-top:15px;"/>

    </div>

  </el-form>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageBaseInformationStationBatchEdit;false">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { stationApi } from '/@/api/baseinformation/station';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;


// 定义变量内容
const formRefStation = ref();
const stateStation = reactive({
    vmModel: {
	  LinkedVM:{
        LineCodeId: null,
        StationName: '',
        Base_Status: undefined,
        StationManagerID: '',
        StationManagerName: '',
      },
      Ids:[],
      
	},
    
    AllLineCodes: [] as any[],
});

// 取消
const onCloseStation = () => {
    closeDialog();
};

// 提交
const onSubmitStation = () => {
	const loadingInstance = ElLoading.service({
		lock: true,
		text: '正在提交中，请等待。。。',
		background: 'rgba(0, 0, 0, 0.7)',
	});

    formRefStation.value?.validate((valid: boolean, fields: any) => {
		if (valid) {
            stationApi().batchedit(stateStation.vmModel).then(() => {
                ElMessage.success(ci.proxy.$t('message._system.common.vm.submittip'));
                emit('refresh');
                closeDialog();
            }).catch((error:any) => {
                other.setFormError(ci, error);
            }).finally(() => {
			loadingInstance.close();
		    })
		}
	})
};


// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/BaseInformation/Station/GetLines',[],false).then(x=>{stateStation.AllLineCodes = x});
    if (ci.attrs["wtmdata"]) {
		stateStation.vmModel.Ids = ci.attrs["wtmdata"];
	}
	else if (useRouter().currentRoute.value.query.id) {
		stateStation.vmModel.Ids = useRouter().currentRoute.value.query.id as any;
	}

});

// 定义子组件向父组件传值/事件
const emit = defineEmits(['refresh','closeDialog']);
// 关闭弹窗
const closeDialog = () => {
    emit('closeDialog');
};
// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

